//package vben.core.framework.ldap;
//
//
//import org.springframework.beans.factory.annotation.Value;
//import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
//import org.springframework.context.annotation.Bean;
//import org.springframework.context.annotation.Configuration;
//import org.springframework.ldap.core.LdapTemplate;
//import org.springframework.ldap.core.support.LdapContextSource;
//
//import java.util.HashMap;
//import java.util.Map;
//
//@Configuration
////@ConditionalOnProperty(prefix="ldap",name = "enable", havingValue = "true")
//public class LdapConfig {
//
//    @Value("${ldap.url}")
//    private String ldapUrl;
//
//    @Value("${ldap.base}")
//    private String ldapBase;
//
//    @Value("${ldap.userDn}")
//    private String ldapUserDn;
//
//    @Value("${ldap.userPwd}")
//    private String ldapUserPwd;
//
//    @Value("${ldap.referral}")
//    private String ldapReferral;
//
//    @Bean
//    public LdapTemplate ldapTemplate() {
//        return new LdapTemplate(contextSourceTarget());
//    }
//
//    @Bean
//    public LdapContextSource contextSourceTarget() {
//        LdapContextSource ldapContextSource = new LdapContextSource();
//        ldapContextSource.setUrl(ldapUrl);
//        ldapContextSource.setBase(ldapBase);
//        ldapContextSource.setUserDn(ldapUserDn);
//        ldapContextSource.setPassword(ldapUserPwd);
//        ldapContextSource.setReferral(ldapReferral);
//        Map<String, Object> config = new HashMap();
//        config.put("java.naming.ldap.attributes.binary", "objectGUID");
////        config.put("com.sun.jndi.ldap.read.timeout","3000");
//        ldapContextSource.setPooled(false);
//        ldapContextSource.setBaseEnvironmentProperties(config);
//        return ldapContextSource;
//    }
//}